package com.chucang.shucang.usr.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/10/10 15:48
 * @description
 */
@Configuration
public class RedissonConfig {

    @Value("${spring.klock.address}")
    private String address;
    @Value("${spring.klock.password}")
    private String password;

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + address).setPassword(password);
        return Redisson.create(config);
    }
}
